﻿using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Management.Automation;
using PowerOBIProvider;
using System.Collections.ObjectModel;

namespace PowerOBIProvider.Cmdlts
{
    public class BaseOBICmdlt : PSCmdlet
    {
        public PSOBIDriveInfo GetOBIDrive(PathInfo mPSPath)
        {
            if (mPSPath != null)
                return mPSPath.Drive as PSOBIDriveInfo;
            else return null;
        }

        public PathInfo GetPathInfoFromPath(string mPath)
        {
            try
            {
                Collection<PathInfo> paths = SessionState.Path.GetResolvedPSPathFromPSPath(mPath.TrimEnd('/'));
                if (paths.Count == 1)
                    return paths[0];
                else
                    return null;
            }
            catch (Exception ex)
            {
                return null;
            }
        }
    }
}
